#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )

package ${package}.types.common;
import lombok.Getter;

import java.util.Arrays;

/**
 * 状态码
 */
@Getter
public enum ReturnCodeEnum {
    RC200("200","success"),
    RC201("201","新建或修改数据成功"),
    RC202("202","请求已经进入队列"),
    RC204("204","删除数据成功"),
    RC301("301","永久重定向"),
    RC302("302","暂时重定向"),
    RC400("400","发出的请求有错误，服务器没有进行新建或修改数据的操作"),
    RC401("401","无访问权限,请联系管理员授予权限"),
    RC403("403","已授权，但是访问是被禁止的"),
    RC404("404","页面找不到异常"),
    RC406("406","请求格式错误"),
    RC410("410","请求资源已被永久删除"),
    RC422("422","创建对象验证失败"),
    RC500("500","服务器内部错误");

    /**自定义状态码**/
    private final String code;
    /**自定义描述**/
    private final String message;

    ReturnCodeEnum(String code, String message){
        this.code = code;
        this.message = message;
    }

    //遍历枚举V1
    public static ReturnCodeEnum getReturnCodeEnum(String code)
    {
        for (ReturnCodeEnum element : ReturnCodeEnum.values()) {
            if(element.getCode().equalsIgnoreCase(code))
            {
                return element;
            }
        }
        return null;
    }
    //遍历枚举V2
    public static ReturnCodeEnum getReturnCodeEnumV2(String code)
    {
        return Arrays.stream(ReturnCodeEnum.values()).filter(x -> x.getCode().equalsIgnoreCase(code)).findFirst().orElse(null);
    }
}